﻿package game.exchangeddata 
{
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import common.Utility
	import game.events.EventData;
	/**
	 * ...
	 * @author Doan Nguyen Thuy Nha Truc (Bamboo)
	 */
	public class ReportInfo extends EventDispatcher
	{
		
		public var serverDateFrom:String;
		public var serverDateTo:String
		public var valueBetAmount:String;
		public var valueWinlose:String;
		public var valueRollingAmount:String;
		public var valueComType:String;
		public var valueComRate:String;
		public var valueComAmount:String;
		public var valueTotal:String; 
		
		public function ReportInfo() 
		{
			init();
		}
		public  function init():void {
			valueBetAmount = "0";
			valueWinlose = "0";
			valueRollingAmount = "0";
			valueComType = "0";
			valueComRate = "0";
			valueComAmount = "0";
			valueTotal = "0";
		}
		/**
		 * @author	Bamboo
		 * @param	result
		 */
		public function resultServerDateTime(result:String):void {
			var dateArr:Array = result.split("-");
			var splitDate:String  = "/";
			var dateTemp:Date;
			var dayTemp:int;
			if (int(dateArr[3]) < 12)
			{	
				dayTemp = int(dateArr[2]) - 1;
				dateTemp = new Date(dateArr[0], dateArr[1], dayTemp);
				serverDateFrom = dateTemp.getDate()  + splitDate + Utility.getMonthString(dateTemp.getMonth())  + splitDate + dateTemp.getFullYear();
				serverDateTo = dateArr[2] + splitDate + Utility.getMonthString(int(dateArr[1])) + splitDate + dateArr[0];
				
			}
			else
			{
				dayTemp = int(dateArr[2]) + 1;
				dateTemp = new Date(dateArr[0] , dateArr[1], dayTemp);
				serverDateFrom = dateArr[2] + splitDate + Utility.getMonthString(int(dateArr[1])) + splitDate + dateArr[0];
				serverDateTo = dateTemp.getDate()  + splitDate + Utility.getMonthString(dateTemp.getMonth())  + splitDate + dateTemp.getFullYear();
			}
			dispatchEvent(new Event(EventData.UPDATE_DATE_REPORT));
		}
		
		public function resultMemberWinLose(result:String) {
			init();
			var offset:int = 2;
			var tempLeng_1:int = 14;
			var tempLeng_2:int = 10;
			this.valueBetAmount = result.substr(offset, tempLeng_1);
			offset += tempLeng_1;
			this.valueWinlose = result.substr(offset, tempLeng_1);
			if (result.substr(1, 1) == "1") {
				offset += tempLeng_1;
				this.valueRollingAmount = result.substr(offset, tempLeng_1);
				offset += tempLeng_1;
				this.valueComType = result.substr(offset, 1);
				offset += 1;
				this.valueComRate = result.substr(offset, tempLeng_2) + " %";
				offset += tempLeng_2;
				this.valueComAmount = result.substr(offset, tempLeng_1);
				offset += tempLeng_1;
				this.valueTotal = result.substr(offset, tempLeng_1);
			}
			
			dispatchEvent(new Event(EventData.UPDATE_VALUE_REPORT));
		}
	}

}